def produce():
    print("PRODUCE")
    for i in range(8):
        print("produce %d" % i)
        yield i

def filter():
    print("\tFILTER")
    producer = produce()
    for i in range(8):
        item = next(producer)*10
        print('\tfilter',i,'->',item)
        yield item

def consume():
    print("\t\tconsume")
    filters = filter()
    for i in range(8):
        item = next(filters)
        print('\t\tconsume',item)

consume()

